package org.hepeng.fabric.gateway.event;

import org.hyperledger.fabric.client.Network;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author he peng
 * @date 2022/3/30
 */
public abstract class NetworkCache {

    private static final Map<String , Network> NETWORK_CACHE = new ConcurrentHashMap<>();

    public static void put(String chaincodeName , Network network) {
        NETWORK_CACHE.putIfAbsent(chaincodeName , network);
    }

    public static Network get(String chaincodeName) {
        return NETWORK_CACHE.get(chaincodeName);
    }

    public static void remove(String chaincodeName) {
        NETWORK_CACHE.remove(chaincodeName);
    }
}
